/************************************************************************/
/* Game                                                                 */
/************************************************************************/
#include "Game/Game Objects/Towers/FlowerTower.h"

namespace TD_Game {


	/************************************************************************/
	/* Flower tower definitions                                             */
	/************************************************************************/
	
	const int FlowerTower::shootingInterval[NUMBER_OF_LEVELS] =				{1500, 1500, 1500, 1500};
	const unsigned int FlowerTower::towerRadius[NUMBER_OF_LEVELS] =			{170, 200, 200, 200, 225, 225};
	const unsigned int FlowerTower::towerDamage[NUMBER_OF_LEVELS] =			{30, 50, 78, 95, 120, 140};
	const unsigned int FlowerTower::towerPrice[NUMBER_OF_LEVELS] =			{30, 55, 88, 110, 145, 180};
	const unsigned int FlowerTower::towerValue[NUMBER_OF_LEVELS] =			{35, 75, 175, 220};
	const string FlowerTower::towerName = "Torre Flower";

	
	const FlowerTower *FlowerTower::m_pStaticReference = NULL;
	shared_ptr<SDLSound> FlowerTower::m_pHittedSound = shared_ptr<SDLSound>();
	shared_ptr<SDLSound> FlowerTower::m_pLaunchSound = shared_ptr<SDLSound>();


	/************************************************************************/
	/* Protected functions                                                  */
	/************************************************************************/
	void FlowerTower::initBaseValues() {
		for(unsigned int i = 0; i < NUMBER_OF_LEVELS; i++) {
			m_shootingInterval[i] = shootingInterval[i];
			m_towerDamage[i] = towerDamage[i];
			m_towerRange[i] = towerRadius[i];
			m_towerPrice[i] = towerPrice[i];
			m_towerValue[i] = towerValue[i];
		}
		m_towerName = towerName;

		m_pDescriptionTile = new Tile(Coord2D(0.81191*screenWidth, 0.375*screenHeight), Coord2D(184, 74), 
			imgTile, TD_Resources::ResourceManager::loadImage("GUI/Descriptions/flowerTowerDescription.png", Color::PINK));
		m_baseTowerType = flowerTower_lvl1;
		m_baseShotType = fireShot_lvl1;
		//Upgrade bar displacement
		m_upBarDisplacement = Coord2D(-15, 50);
	}

	FlowerTower::FlowerTower() {
		initBaseValues();
	}
	FlowerTower::FlowerTower(const FlowerTower & rhs) {

	}

	FlowerTower & FlowerTower::operator=(const FlowerTower &rhs) {
		BaseTower::operator=(rhs);
		return(*this);
	}

	FlowerTower::FlowerTower(unsigned int g_ID, const Coord2D & turretPosition) : BaseTower (g_ID, turretPosition) {

		initBaseValues();

		m_pAnimationSet = AnimationSetFactory::createTowerAnimationSet(flowerTower_lvl1, "Idle");
		m_pBaseShotAS = AnimationSetFactory::createShotAnimationSet(fireShot_lvl1, "Moving");

		m_shapes.push_back(new RectangleShape(turretPosition - m_pAnimationSet->getSprites()->getTilesize()/2, m_pAnimationSet->getSprites()->getTilesize()));
	}

	FlowerTower::~FlowerTower() {

	}

	const FlowerTower * FlowerTower::getStaticReference() {
		if(m_pStaticReference ==  NULL) {
			m_pStaticReference = new FlowerTower();
			m_pLaunchSound = TD_Resources::ResourceManager::loadSound("SFX/sounds/fireTowerLaunch.wav");
			m_pHittedSound = TD_Resources::ResourceManager::loadSound("SFX/sounds/fireTowerHit.wav");
		}
		return(m_pStaticReference);
	}
}